﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CSharpDesign.DAL;

namespace CSharpDesign
{
    public partial class MasterPage : System.Web.UI.MasterPage
    {
        SqlHelper data = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {


                DropDownList1.DataSource = data.GetDataReader("select * from ShangPinFenLei");
                DropDownList1.DataValueField = "id";
                DropDownList1.DataTextField = "name";
                DropDownList1.DataBind();
                DropDownList1.Items.Add("所有类别");
                DropDownList1.Items[this.DropDownList1.Items.Count - 1].Value = " ";
                DropDownList1.SelectedIndex = this.DropDownList1.Items.Count - 1;

                DlGoodsType.DataSource = data.GetDataReader("select * from  ShangPinFenLei  order by  id desc ");
                DlGoodsType.DataBind();

            }

        }
        protected string CutChar(string strChar, int intLength)
        {
            //取得自定义长度的字符串
            if (strChar.Length > intLength)
            { return strChar.Substring(0, intLength); }
            else
            { return strChar; }

        }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            Response.Redirect("SearchShangPinList.aspx?SPName=" + TxtName.Text + "&ShangPinFenLeiName=" + DropDownList1.SelectedItem.Text);
        }
    }

}